package com.um.jdy.app.shop.entity.dto;

import com.um.springboot.starter.entity.dto.PageQuery;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @Title
 * @Description
 * @Author renjunwei
 * @Date 2023/2/16 14:09
 */
@Valid
@Data
@NoArgsConstructor
public class GoodsPageDTO extends PageQuery {

    @ApiModelProperty(value = "商品类目编码")
    private String code;

    @ApiModelProperty(value = "商品名称")
    private String shopGoodsName;

    @ApiModelProperty(value = "排序，null为综合排序")
    private List<Sort> sorts;

    @Valid
    @Data
    public static class Sort {

        @NotNull
        @ApiModelProperty(value = "类型：Price价格、New新品、Sales销量")
        private Filed filed;

        @NotNull
        @ApiModelProperty(value = "顺序：Asc升序、Desc降序")
        private Order order;
    }

    @Getter
    @AllArgsConstructor
    public enum Filed{
        Price("g.price"),
        New("g.create_date"),
        Sales("o.order_num"),
        ;

        private String value;
    }

    public enum Order{
        Asc, Desc
    }

    public GoodsPageDTO(int pageNo, int pageSize){
        this.setPage_no(pageNo);
        this.setPage_size(pageSize);
    }

}
